00001
00002 CommandSelectAll::CommandSelectAll(OSGWindows* osgwind)
00003 {
00004
00005 osgwind_ = osgwind;
00006
00007 }
00008
00009 bool CommandSelectAll::execute()
00010 {
00011 int size= (int)osgwind_->getObjects().size();
00012 for(int i=0;i<size;i++)
00013 {
00014 if(osgwind_->getObjects().at(i)->getCondition()== 'a')
00015 {
00016 stateset=osgwind_->getObjects().at(i)->getPAT()->getOrCreateStateSet();
00017 changeState();
00018 osgwind_->setSelectedObjects(osgwind_->getObjects().at(i));
00019 }
00020 }
00021 return true;
00022 }
00023
00024
00025 void CommandSelectAll::changeState()
00026 {
00027 stateset->setMode(GL_BLEND, osg::StateAttribute::ON);
00028 osg::Material* material = new osg::Material;
00029 material->setDiffuse(osg::Material::FRONT_AND_BACK, osg::Vec4(0.2f,0.2f,1.0f,1.0f));
00030 stateset->setAttributeAndModes(material, osg::StateAttribute::ON|osg::StateAttribute::OVERRIDE);
00031 }
00032
00033 bool CommandSelectAll::unexecute()
00034 {
00035 int size=(int)osgwind_->getObjects().size();
00036
00037 for(int i=0;i<size;i++)
00038 {
00039 if(osgwind_->getObjects().at(i)->getCondition()== 'a')
00040 {
00041 stateset=osgwind_->getObjects().at(i)->getPAT()->getOrCreateStateSet();
00042 changeStateReverse();
00043 }
00044 }
00045
00046 osgwind_->clearSelectedObjects();
00047
00048 return true;
00049 }
00050
00051 void CommandSelectAll::changeStateReverse()
00052 {
00053 stateset->setMode(GL_BLEND, osg::StateAttribute::ON);
00054 osg::Material* material = new osg::Material;
00055 material->setDiffuse(osg::Material::FRONT_AND_BACK, osg::Vec4(1.0f,1.0f,1.0f,1.0f));
00056 stateset->setAttributeAndModes(material, osg::StateAttribute::ON);
00057 }